package com.hinnotek.warehouse.viewmodel

import android.app.Application
import androidx.lifecycle.Transformations
import com.hinnotek.warehouse.api.WarehouseApi
import com.lee.common.utils.SharedPreUtils
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class WarehouseViewModel @Inject constructor() :
    BaseViewModel() {


    var wareId = 0

    private val warehouse = Transformations.switchMap(page) {
        api.getSysWarehouseListByUserId(SharedPreUtils.getInteger("userId", 0))
    }

    private val warehouseDetail = Transformations.switchMap(page) {
        api.getSysWarehouseDetailPageById(keyInt, it, 10)
    }

    private val warehouseNum = Transformations.switchMap(page) {
        api.getWarehouseNumDetail(wareId)
    }

    val warehousePage = mapPage(warehouse)

    val warehouseDetailPage = mapPage(warehouseDetail)

    val warehouseNumPage = mapPage(warehouseNum)


}